/*
 * Copyright 2018, 2019, 2020 Dooboolab.
 *
 * This file is part of Flutter-Sound.
 *
 * Flutter-Sound is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3 (LGPL-V3), as published by
 * the Free Software Foundation.
 *
 * Flutter-Sound is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Flutter-Sound.  If not, see <https://www.gnu.org/licenses/>.
 */


import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_sound/flutter_sound.dart' hide SoundPlayerUI;

import 'demo_active_codec.dart';
import 'sound_player_ui.dart';


class RemotePlayer extends StatefulWidget {
  String audioFilePath ;
  int type ;

  RemotePlayer(this.audioFilePath,this.type);

  @override
  State<StatefulWidget> createState() {
    return RemotePlayerState();
  }
}
///
class RemotePlayerState extends State<RemotePlayer> {
  @override
  Widget build(BuildContext context) {
    return SoundPlayerUI.fromTrack(
      Track(trackPath: widget.audioFilePath, codec: ActiveCodec().codec),
      type: widget.type,
      showTitle: false,
      audioFocus: AudioFocus.requestFocusAndDuckOthers,
      textStyle: TextStyle(fontSize: 12,color: Color.fromRGBO(214, 178, 128, 1)),
      backgroundColor:Colors.white,
      sliderThemeData: SliderThemeData(
        trackHeight:1,
        activeTrackColor:Colors.lightGreenAccent,
        inactiveTrackColor:Colors.orange,
        disabledActiveTrackColor:Colors.limeAccent,
        disabledInactiveTrackColor:Colors.pinkAccent,
        activeTickMarkColor:Colors.tealAccent,
      ),
    );
  }

  Future<Track> _createRemoteTrack(BuildContext context) async {
    Track track = Track(trackPath: widget.audioFilePath, codec: ActiveCodec().codec);

    track.trackTitle = "Remote mpeg playback.";
    track.trackAuthor = "By flutter_sound";
//      track.albumArtUrl = widget.albumArtPath;

    if (Platform.isIOS) {
      track.albumArtAsset = 'AppIcon';
    } else if (Platform.isAndroid) {
      track.albumArtAsset = 'AppIcon.png';
    }

    return track;
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }
}
